package com.wm.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wm.common.utils.StringUtils;
import com.wm.system.domain.BrandLibrary;
import com.wm.system.mapper.BrandLibraryMapper;
import com.wm.system.service.IBrandLibraryService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 品牌库 服务实现类
 * </p>
 *
 * @author hyq
 * @since 2023-10-21 16:34:02
 */
@Service
public class BrandLibraryServiceImpl extends ServiceImpl<BrandLibraryMapper, BrandLibrary> implements IBrandLibraryService {

    @Override
    public List<BrandLibrary>  selectBrandLibraryList(BrandLibrary brandLibrary) {

        List<BrandLibrary> list = this.lambdaQuery().like(StringUtils.isNotEmpty(brandLibrary.getBrandName()),BrandLibrary::getBrandName, brandLibrary.getBrandName())
                .list();
        return list;
    }

    @Override
    public void addOrUpdate(BrandLibrary brandLibrary) {

        if(brandLibrary.getId()!=null){
            brandLibrary.setCreatTime(LocalDateTime.now());
        }
        this.saveOrUpdate(brandLibrary);
    }
}
